﻿@using Lib.core;
@using Lib.helper;

@using Bll;
@using Model;
@using WebLogic.Model.User;
@using WebLogic.Bll.User;
@using Model.User;
@{
    Layout = null;

    var list = ViewData["list"] as IList<UserModel>;
}

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!-- header page -->
    @Html.Partial(IncludePath("header"))
</head>

<body>
    @Html.Partial(IncludePath("body_top"))
    @Html.Partial(IncludePath("manage_nav"))

    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="col-md-6"></div>
                    <div class="col-md-6">
                        <form method="get" action="/admin/user/userlist/" target="_self">
                            <div class="input-group">
                                <input type="text" class="form-control" name="q" placeholder="搜索用户..." value="@(ViewData["q"])" />
                                <span class="input-group-btn">
                                    <button type="submit" class="btn">搜索</button>
                                </span>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="box">
                    <table class="table table-hover table-responsive">
                        <thead>
                            <tr>
                                <td>ID</td>
                                <td>昵称</td>
                                <td>邮箱</td>
                                <td>性别</td>
                                <td>电话</td>
                                <td>余额</td>
                                <td style="width:20%;">角色</td>
                                <td>操作</td>
                            </tr>
                        </thead>
                        <tbody>
                            @if (ValidateHelper.IsPlumpList(list))
                            {
                                foreach (var model in list)
                                {
                                    if (model == null) { continue; }
                                    <tr>
                                        <td>@(model.UserID)</td>
                                        <td>@(model.NickName)</td>
                                        <td>@(model.Email)</td>
                                        <td>@(model.Sex)</td>
                                        <td>@(model.Phone)</td>
                                        <td>@(model.Money)</td>
                                        <td>
                                            @if (ValidateHelper.IsPlumpList(model.RoleModelList))
                                            {
                                                foreach (var name in model.RoleModelList.Select(x => x.RoleName).Distinct())
                                                {
                                                    <span class="label label-danger">@(name)</span>
                                                }
                                            }
                                            else
                                            {
                                                <span>无角色</span>
                                            }
                                        </td>
                                        <td>
                                            <a href="/admin/permission/userrole/?user_id=@(model.UserID)" target="_blank">角色管理</a>
                                        </td>
                                    </tr>
                                }
                            }
                        </tbody>
                    </table>
                </div>
                <div class="box">
                    @(Html.Raw(ViewData["pager"]))
                </div>
            </div>
        </div>
    </div>
    @Html.Partial(IncludePath("body_bottom"))
</body>
</html>
